'use strict';

/**
 * @param {Egg.Application} app - egg application
 */
module.exports = (app) => {
  const { router, controller } = app;
  const preRouter = '/api/blog';

  // 图片上传
  router.post(
    preRouter + '/imgUpload',

    controller.blog.file.imgUpload
  );

  /** 用户模块 */
  // 关注
  router.post(
    preRouter + '/user/follow',

    controller.blog.user.follow
  );
  // 获取用户信息
  router.get(
    preRouter + '/user/searchUser',

    controller.blog.user.searchUser
  );
  // 迁移学生信息
  router.post(preRouter + '/student/move', controller.blog.student.move);
  // 注册
  router.post(preRouter + '/user/register', controller.blog.user.register);
  // 判断是否已注册
  router.post(preRouter + '/user/isRegister', controller.blog.user.isRegister);
  // 登录
  router.post(preRouter + '/user/login', controller.blog.user.login);
  // 重置密码
  router.put(
    preRouter + '/user/resetPassword',

    controller.blog.user.resetPassword
  );
  // 编辑个人信息
  router.put(
    preRouter + '/user/edit',

    controller.blog.user.edit
  );
  // 获取我点赞过的博客
  router.get(
    preRouter + '/user/getLikeBlog',

    controller.blog.user.getLikeBlog
  );
  // 获取关注的用户
  router.get(
    preRouter + '/user/getLikeUser',

    controller.blog.user.getLikeUser
  );

  /** 管理员模块*/
  // 获取项目所有博客
  router.get(
    preRouter + '/admin/getProjectBlog',

    controller.blog.admin.getProjectBlog
  );
  // 根据关键词查找博客
  router.get(
    preRouter + '/admin/getByKeyword',

    controller.blog.admin.getByKeyword
  );
  // 博客删除
  router.delete(
    preRouter + '/admin/deleteBlog/:id',

    controller.blog.admin.deleteBlog
  );
  // 获取博客所有评论
  router.get(
    preRouter + '/admin/getBlogComment',

    controller.blog.admin.getBlogComment
  );
  // 删除评论
  router.delete(
    preRouter + '/admin/deleteComment/:id',

    controller.blog.admin.deleteComment
  );
  // 获取项目所有评论
  router.get(
    preRouter + '/admin/getProjectComment',

    controller.blog.admin.getProjectComment
  );
  // 根据id获取博客
  router.get(
    preRouter + '/admin/getBlogById',

    controller.blog.admin.getBlogById
  );

  // /** 超管模块*/
  // // 根据项目id获取项目所有博客
  // router.get(
  //   preRouter + '/superAdmin/getProjectBlog',
  //
  //   controller.blog.superAdmin.getProjectBlog
  // );
  // // 获取所有项目
  // router.get(
  //   preRouter + '/superAdmin/getAllProject',
  //
  //   controller.blog.superAdmin.getAllProject
  // );
  // // 根据id获取博客
  // router.get(
  //   preRouter + '/superAdmin/getBlogById',
  //
  //   controller.blog.superAdmin.getBlogById
  // );
  // // 获取所有管理员
  // router.get(
  //   preRouter + '/superAdmin/getAllAdmin',
  //
  //   controller.blog.superAdmin.getAllAdmin
  // );
  // // 获取所有博客
  // router.get(
  //   preRouter + '/superAdmin/getAllBlog',
  //
  //   controller.blog.superAdmin.getAllBlog
  // );
  // // 删除博客
  // router.delete(
  //   preRouter + '/superAdmin/deleteBlog',
  //
  //   controller.blog.superAdmin.deleteBlog
  // );
  // // 获取博客所有评论
  // router.get(
  //   preRouter + '/superAdmin/getBlogComment',
  //
  //   controller.blog.superAdmin.getBlogComment
  // );
  // // 获取所有项目的评论
  // router.get(
  //   preRouter + '/superAdmin/getAllComment',
  //
  //   controller.blog.superAdmin.getAllComment
  // );
  // // 删除评论
  // router.delete(
  //   preRouter + '/superAdmin/deleteComment',
  //
  //   controller.blog.superAdmin.deleteComment
  // );
  // // 根据id查找项目
  // router.get(
  //   preRouter + '/superAdmin/getProjectById',
  //
  //   controller.blog.superAdmin.getProjectById
  // );

  /* 图片模块**/
  router.post(preRouter + '/imgUpload', controller.blog.file.imgUpload);

  /** 博客模块*/
  // 创建博客
  router.post(
    preRouter + '/blog/create',

    controller.blog.blog.create
  );
  // 获取所有博客
  router.get(preRouter + '/blog/getAllBlog', controller.blog.blog.getAllBlog);
  // 通过博客id搜索博客
  router.get(preRouter + '/blog/search', controller.blog.blog.searchById);
  // 通过分类id搜索博客
  router.get(
    preRouter + '/blog/searchByClassifyId',
    controller.blog.blog.searchByClassifyId
  );
  // 通过关键词搜索博客
  router.get(
    preRouter + '/blog/searchByInput',
    controller.blog.blog.searchByInput
  );
  // 获取用户自己的博客
  router.get(
    preRouter + '/blog/getMyBlog',

    controller.blog.blog.getMyBlog
  );
  // 更新博客
  router.put(
    preRouter + '/blog/updataBlog',

    controller.blog.blog.updateBlog
  );
  // 删除博客
  router.delete(
    preRouter + '/blog/deleteBlog',

    controller.blog.blog.deleteBlog
  );
  // 点赞博客
  router.post(
    preRouter + '/blog/likeBlog',

    controller.blog.blog.likeBlog
  );
  // 获取浏览博客历史
  router.get(
    preRouter + '/blog/getHistory',

    controller.blog.blog.getHistory
  );

  /** 分类模块*/
  // 创建分类
  router.post(
    preRouter + '/classify/create',

    controller.blog.classify.create
  );
  // 修改分类
  router.put(
    preRouter + '/classify/update/:id',

    controller.blog.classify.update
  );
  // 删除分类
  router.delete(
    preRouter + '/classify/delete/:id',

    controller.blog.classify.delete
  );
  // 获取分类
  router.get(preRouter + '/classify/get', controller.blog.classify.get);

  /** 评论模块 */
  // 创建评论
  router.post(
    preRouter + '/comment/create',

    controller.blog.comment.create
  );
  // 获取当前博客评论
  router.get(preRouter + '/comment/get', controller.blog.comment.get);
  // 获取自己的评论
  router.get(
    preRouter + '/comment/getMyComment',

    controller.blog.comment.getMyComment
  );
  // 获取我收到的回复
  router.get(
    preRouter + '/comment/getMyReply',

    controller.blog.comment.getMyReply
  );
  // 删除评论
  router.delete(
    preRouter + '/comment/delete',

    controller.blog.comment.delete
  );
  // 点赞评论
  router.post(
    preRouter + '/comment/like',

    controller.blog.comment.like
  );
};
